package org.algorithm.落雪.字符串;

/**
 * @Date 2022/2/23
 * @Link {https://leetcode-cn.com/problems/excel-sheet-column-number/}
 */
public class Excel表列序号 {

    public static void main(String[] args) {
        System.out.println(titleToNumber("ZC"));
    }

    public static int titleToNumber(String s) {

        int result = 0;
        int length = s.length();

        for (int i = 0; i < length; i++) {
            result = result * 26 + (s.charAt(i) - 'A' + 1);
        }
        return result;

    }
}
